{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 最小二乘法求一元线性回归\n",
    "\n",
    "y = 4x+2\n",
    "\n",
    "## 构造数据集"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "np.random.seed(0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "# p.random.normal(loc=0.0, scale=1.0, size=None)的意思是一个正态分布，normal这里是正态的意思\n",
    "# loc：float\n",
    "#     此概率分布的均值（对应着整个分布的中心centre）\n",
    "# scale：float\n",
    "#     此概率分布的标准差（对应于分布的宽度，scale越大越矮胖，scale越小，越瘦高）\n",
    "# size：int or tuple of ints\n",
    "#     输出的shape，默认为None，只输出一个值\n",
    "X = np.random.normal(size=(100,1),scale=1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "y = 4* X[:,0] +2 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "import matplotlib.pyplot as plt  # pip install matplotlib"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.collections.PathCollection at 0x21adcc32ac8>"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXwAAAD4CAYAAADvsV2wAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy86wFpkAAAACXBIWXMAAAsTAAALEwEAmpwYAAAYX0lEQVR4nO3df5DcdZ3n8ecrQ7s1sN4NFkHMkNl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SfvrLUgw6Pzd/d2zppe/u0s6ZmYZ4cA3M8sIB3537Eh7ACnyd88mf/ce5Bq+mVlG+ArfzCwjHPhmZhnhwO8CSdslPS3pCUn3SRpJe0zdJOm3JR2SdEJST05XS5KkqyRNSzos6Za0x9NNku6S9JKkJ9MeS7dJWinp+5KeKv19/y9pj6maA7879gL/PiLeDvw/YEvK4+m2J4ENwINpD6TTJA0BXwauBt4KbJT01nRH1VV/A1yV9iBSchy4OSJ+E7gM+ESv/W/vwO+CiHggIo6X3u4Dzk9zPN0WEU9FRFZWkr8EOBwRz0bEr4BvANekPKauiYgHgZ+nPY40RMQLEfFY6fUrwFNATy3O4cDvvt8DvpP2IKxjRoHnK94focf+0VvnSVoFXAw8kvJQTjFwK16lRdL3gPNq7Lo1Iu4vHXMrxf/bt7ObY+uGZr5/RqjGNs99zhBJvw58E/hkRPwy7fFUcuAnJCLevdR+SR8B3gu8Kwbw4YdG3z9DjgArK96fD8ykNBbrMkk5imG/MyJ2pT2eai7pdIGkq4BPAe+PiGNpj8c66lFgtaQ3S3odcAOwO+UxWRdIEvDXwFMRcUfa46nFgd8dXwJeD+yVdFDSnWkPqJskfUDSEeBy4NuSJtIeU6eUbs7fBExQvGl3b0QcSndU3SPpbuBhYI2kI5J+P+0xddFa4MPAFaV/5wclrU97UJXcWsHMLCN8hW9mlhEOfDOzjHDgm5llhAPfzCwjHPhmZhnhwDczywgHvplZRvx/SJPH2bxIrtEAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.scatter(X,y)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "((100,), (100, 1))"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "y.shape,X.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(100, 2)"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "All_data = np.concatenate((X,y.reshape(100,1)),axis=1)\n",
    "All_data.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[-0.85409574, -1.41638296],\n",
       "       [ 0.95008842,  5.80035367],\n",
       "       [-0.4380743 ,  0.24770279],\n",
       "       [ 0.3024719 ,  3.20988759],\n",
       "       [ 0.8644362 ,  5.4577448 ],\n",
       "       [-1.45436567, -3.8174627 ],\n",
       "       [-1.61389785, -4.45559139],\n",
       "       [ 0.15494743,  2.6197897 ],\n",
       "       [-0.36274117,  0.54903534],\n",
       "       [-1.23482582, -2.93930328],\n",
       "       [ 0.33367433,  3.33469731],\n",
       "       [ 0.76103773,  5.0441509 ],\n",
       "       [-0.21274028,  1.14903888],\n",
       "       [ 0.70657317,  4.82629267],\n",
       "       [ 0.44386323,  3.77545293],\n",
       "       [-0.89546656, -1.58186624],\n",
       "       [ 1.05445173,  6.21780691],\n",
       "       [-1.70627019, -4.82508076],\n",
       "       [-0.51080514, -0.04322055],\n",
       "       [ 1.23029068,  6.92116272],\n",
       "       [ 1.86755799,  9.47023196],\n",
       "       [-0.31155253,  0.75378987],\n",
       "       [ 0.40234164,  3.60936656],\n",
       "       [ 0.77749036,  5.10996142],\n",
       "       [-0.90729836, -1.62919346],\n",
       "       [-0.20515826,  1.17936694],\n",
       "       [-1.53624369, -4.14497475],\n",
       "       [-0.10321885,  1.58712459],\n",
       "       [ 1.49407907,  7.97631629],\n",
       "       [-1.07075262, -2.28301049],\n",
       "       [-0.68481009, -0.73924036],\n",
       "       [-1.16514984, -2.66059936],\n",
       "       [ 1.13940068,  6.55760274],\n",
       "       [ 1.76405235,  9.05620938],\n",
       "       [-0.97727788, -1.90911152],\n",
       "       [-0.67246045, -0.68984179],\n",
       "       [ 0.90082649,  5.60330595],\n",
       "       [ 1.48825219,  7.95300878],\n",
       "       [-0.34791215,  0.6083514 ],\n",
       "       [-1.98079647, -5.92318587],\n",
       "       [ 0.6536186 ,  4.61447438],\n",
       "       [ 0.97663904,  5.90655615],\n",
       "       [-0.15135721,  1.39457117],\n",
       "       [-1.63019835, -4.52079339],\n",
       "       [ 0.3563664 ,  3.42546559],\n",
       "       [ 0.12691209,  2.50764837],\n",
       "       [ 0.01050002,  2.04200008],\n",
       "       [-1.7262826 , -4.90513041],\n",
       "       [ 0.46566244,  3.86264976],\n",
       "       [ 0.04575852,  2.18303407],\n",
       "       [-0.81314628, -1.25258513],\n",
       "       [-0.63432209, -0.53728837],\n",
       "       [-0.40178094,  0.39287626],\n",
       "       [-0.40317695,  0.38729221],\n",
       "       [ 0.42833187,  3.71332748],\n",
       "       [ 0.4105985 ,  3.64239401],\n",
       "       [-0.30230275,  0.790789  ],\n",
       "       [-0.57884966, -0.31539866],\n",
       "       [ 1.17877957,  6.71511828],\n",
       "       [ 1.46935877,  7.87743508],\n",
       "       [ 0.17742614,  2.70970457],\n",
       "       [-2.55298982, -8.21195926],\n",
       "       [-1.25279536, -3.01118144],\n",
       "       [ 0.3869025 ,  3.54760999],\n",
       "       [-1.18063218, -2.72252874],\n",
       "       [-0.74216502, -0.96866008],\n",
       "       [-0.18718385,  1.2512646 ],\n",
       "       [ 0.97873798,  5.91495194],\n",
       "       [ 1.53277921,  8.13111686],\n",
       "       [ 1.20237985,  6.8095194 ]])"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 拆分为训练集和测试集\n",
    "#打乱\n",
    "np.random.shuffle(All_data)\n",
    "# x[n,:]表示在n个数组（维）中取全部数据，直观来说，x[n,:]就是取第n集合的所有数据, \n",
    "# x[:,m:n]，即取所有数据集的第m到n-1列数据\n",
    "train_data = All_data[:70,:]\n",
    "test_data = All_data[70:,:]\n",
    "train_data"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 构造模型\n",
    "y = w*x + b"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(array([-1.55602368]), 0.25435648177039294)"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#随机初始化参数\n",
    "W = np.random.normal(size=(1))\n",
    "b = np.random.rand()\n",
    "W,b"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##  定义损失函数\n",
    "$loss=0.5*\\sum((y-Wx)^2)|$"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": [
    "lr = 0.001 #学习率"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(2, 1)"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 构造增广矩阵\n",
    "# 先转为列表，在连接\n",
    "W_hat = np.concatenate((W,np.array([b])))\n",
    "W_hat = W_hat.reshape(2,1)\n",
    "W_hat.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(1, 70)"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# -1行也就是最后一行前面的，都是X值（不包括最后一行）。 最后一行是Y值\n",
    "X = train_data[:,:-1]\n",
    "# 逗号分隔开的前面的\":\"是说取全部的行，逗号后面的-1是说取最后一列\n",
    "y = train_data[:,-1]\n",
    "# X\n",
    "X = X.reshape(1,70)\n",
    "X.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(2, 70)"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 构造曾广特征向量\n",
    "X_hat = np.concatenate((X,np.ones((1,70))),axis=0)\n",
    "X_hat.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "((70, 70), (70,))"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "(y-np.dot(X_hat.T,W_hat)).shape, y.shape\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(2, 1)"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "(np.dot(X_hat,(y.reshape(70,1)-np.dot(X_hat.T,W_hat)))).shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Num: 2,loss: 1002.255625\n",
      "Num: 3,loss: 870.034035\n",
      "Num: 4,loss: 755.319127\n",
      "Num: 5,loss: 655.784093\n",
      "Num: 6,loss: 569.412613\n",
      "Num: 7,loss: 494.457247\n",
      "Num: 8,loss: 429.403439\n",
      "Num: 9,loss: 372.938348\n",
      "Num: 10,loss: 323.923880\n",
      "Num: 11,loss: 281.373328\n",
      "Num: 12,loss: 244.431161\n",
      "Num: 13,loss: 212.355510\n",
      "Num: 14,loss: 184.503010\n",
      "Num: 15,loss: 160.315670\n",
      "Num: 16,loss: 139.309497\n",
      "Num: 17,loss: 121.064647\n",
      "Num: 18,loss: 105.216890\n",
      "Num: 19,loss: 91.450212\n",
      "Num: 20,loss: 79.490412\n",
      "Num: 21,loss: 69.099545\n",
      "Num: 22,loss: 60.071111\n",
      "Num: 23,loss: 52.225886\n",
      "Num: 24,loss: 45.408305\n",
      "Num: 25,loss: 39.483324\n",
      "Num: 26,loss: 34.333708\n",
      "Num: 27,loss: 29.857671\n",
      "Num: 28,loss: 25.966835\n",
      "Num: 29,loss: 22.584454\n",
      "Num: 30,loss: 19.643882\n",
      "Num: 31,loss: 17.087237\n",
      "Num: 32,loss: 14.864242\n",
      "Num: 33,loss: 12.931229\n",
      "Num: 34,loss: 11.250259\n",
      "Num: 35,loss: 9.788376\n",
      "Num: 36,loss: 8.516943\n",
      "Num: 37,loss: 7.411081\n",
      "Num: 38,loss: 6.449167\n",
      "Num: 39,loss: 5.612415\n",
      "Num: 40,loss: 4.884493\n",
      "Num: 41,loss: 4.251210\n",
      "Num: 42,loss: 3.700229\n",
      "Num: 43,loss: 3.220826\n",
      "Num: 44,loss: 2.803678\n",
      "Num: 45,loss: 2.440681\n",
      "Num: 46,loss: 2.124788\n",
      "Num: 47,loss: 1.849871\n",
      "Num: 48,loss: 1.610603\n",
      "Num: 49,loss: 1.402349\n",
      "Num: 50,loss: 1.221080\n",
      "Num: 51,loss: 1.063291\n",
      "Num: 52,loss: 0.925933\n"
     ]
    }
   ],
   "source": [
    "Num = 1\n",
    "w_list = []\n",
    "b_list = []\n",
    "loss_list = []\n",
    "while True:\n",
    "    #更新参数\n",
    "    # np.dot 如果是一维的就是一个简单乘法，二维的就变成矩阵乘法\n",
    "    W_hat = W_hat + lr * np.dot(X_hat,(y.reshape(70,1)-np.dot(X_hat.T,W_hat)))\n",
    "    #计算经验错误\n",
    "    loss = np.sum((y.reshape(70,1)-np.dot(X_hat.T,W_hat))**2)/2\n",
    "    #记录w,b和loss\n",
    "    w_list.append(W_hat[0])\n",
    "    b_list.append(W_hat[1])\n",
    "    loss_list.append(loss)\n",
    "    Num = Num + 1\n",
    "    print(\"Num: %d,loss: %f\" % (Num,loss))\n",
    "    if loss < 1 or Num >1000:\n",
    "        break"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.9259333687888875"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "loss"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([3.85376599])"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "w_list[-1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([1.92006704])"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "b_list[-1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[<matplotlib.lines.Line2D at 0x21aded38dc8>]"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAX0AAAD4CAYAAAAAczaOAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy86wFpkAAAACXBIWXMAAAsTAAALEwEAmpwYAAAf7klEQVR4nO3deXRc9X338fd3ZrRYlmxJlixvsuVFYGQH2yCDCZsDGJyExPRpKE5D6pQ2tHloS3LSJ4We85w0bXlKlpOtDWlIQnBCEuImEJwNMAYCJICRsQHvFniTF0neLcla5/v8MddmMDI2GklXM/N5nTPn3vubezXf3/HxZ+785s7vmrsjIiLZIRJ2ASIiMngU+iIiWUShLyKSRRT6IiJZRKEvIpJFYmEXcCZlZWVeVVUVdhkiImll9erV+929/NT2IR/6VVVV1NXVhV2GiEhaMbMdvbVreEdEJIso9EVEsohCX0Qkiyj0RUSyiEJfRCSLKPRFRLLIGUPfzO4zsyYzW5fUVmpmK8xsa7AsSXruTjOrN7PNZnZdUvuFZvZa8Nw3zcz6vzsiIvJOzuZM/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4U3cBn3f08YB5wW/Bvm8l97gCucvdZwGxgoZnNI7P7DHA7sDFpO9P7e8L73H120vX5/d7vjAt9km6+7u6dwImbr2ccd38GOHhK8yJgabC+FLhhMGsaSO6+191fDtaPkQiF8WR2n93dW4LNnODhZHCfzWwC8EHge0nNGdvfM+j3fmdi6Pd28/XxIdUShgp33wuJkARGh1zPgDCzKmAO8CIZ3udgqGMt0ASscPdM7/PXgc8B8aS2TO7vCQ48bmarzezWoK3f+z3oN1EZBGd183VJX2ZWCPwC+LS7HzXr7Z88c7h7DzDbzIqBh81sZsglDRgzux5ocvfVZjY/5HIG26XuvsfMRgMrzGzTQLxIJp7pZ/vN1xvNbCxAsGwKuZ5+ZWY5JAL/x+7+UNCc0X0+wd0PA0+T+B4nU/t8KfBhM9tOYmj2KjN7gMzt70nuvidYNgEPkxiq7vd+Z2LoZ/vN15cDS4L1JcAjIdbSryxxSv99YKO7fzXpqUzuc3lwho+ZDQOuATaRoX129zvdfYK7V5H4v/uku99Mhvb3BDMbbmZFJ9aBa4F1DEC/M/IXuWb2ARLjgiduvn5XuBUNDDP7KTCfxBSsjcDngV8Cy4CJwE7gRnc/9cvetGRmlwHPAq/x5njvP5MY18/UPp9P4gu8KImTtGXu/q9mNooM7fMJwfDOP7r79ZneXzObQuLsHhLD7j9x97sGot8ZGfoiItK7TBzeERGR01Doi4hkEYW+iEgWUeiLiGQRhb6ISBZR6IuIZBGFvohIFvn/1Sh5DBh9NlkAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.plot(loss_list)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[<matplotlib.lines.Line2D at 0x21adedbfd48>]"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png":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glmjm4wxw40x7xhjio0xm40xtwaOh3Ob44wxK40x6wNt/nHgeNi2+QBjTKQxZq0x5tXAfli32Riz2xiz0RizzhhTFDjmeptDJsiNMZHAI8D5wATgGmPMhOBW1SsWAQuOOHY78La1dgzwdmA/XHQD37PWjgdmAt8I/HcN5zZ3AvOstacBU4AFxpiZhHebD7gVKD5kfyC0+Wxr7ZRD5o673uaQCXJgBrDTWrvLWtsFPA9cEuSaXGetXQbUH3H4EuCpwPungEv7sqbeZK2ttNauCbxvwfklzyG822ytta2B3ejAyxLGbQYwxuQCFwK/P+RwWLf5GFxvcygFeQ6w95D9fYFjA8Fga20lOMEHZAe5nl5hjCkApgIfEeZtDgwxrAOqgSXW2rBvM/AQ8APAf8ixcG+zBd4yxqw2xiwMHHO9zaH08GVzlGOaOxkmjDFJwF+A26y1zcYc7T93+LDW+oApxphU4K/GmFODXFKvMsZcBFRba1cbY84Kcjl9aY61tsIYkw0sMcZs7Y2LhFKPfB8w/JD9XKAiSLX0tSpjzFCAwLY6yPW4yhgTjRPif7TWvhg4HNZtPsBa2wgsxfleJJzbPAe42BizG2dYdJ4x5hnCu81YaysC22rgrzhDxK63OZSCfBUwxhgzwhgTA1wNvBLkmvrKK8CXA++/DLwcxFpcZZyu9+NAsbX2l4f8KJzbnBXoiWOMiQfmA1sJ4zZba++w1uZaawtwfnf/aa29jjBuszEm0RiTfOA9cB6wiV5oc0jd2WmMuQBnnC0SeMJae09wK3KfMeY54CycpS6rgLuBl4DFQB6wB7jSWnvkF6IhyRhzBvAesJGDY6c/xBknD9c2T8b5kisSpzO12Fr7E2NMBmHa5kMFhla+b629KJzbbIwZidMLB2cY+1lr7T290eaQCnIREfmkUBpaERGRo1CQi4iEOAW5iEiIU5CLiIQ4BbmISIhTkIuIhDgFuYhIiPv/2HAK4dDOCEkAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.plot(w_list)\n",
    "plt.plot(b_list)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
